package com.isoftstone.demo.global.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.isoftstone.dreambase.utils.DateUtil;
import com.isoftstone.services.base.entity.User;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

/**
 * Demo实体类
 *
 * @author TianGanLin
 * @version 1.0.0, 2017/11/24
 * @since 1.8
 */
@Entity
@Table(name = "SM_DEMO")
@DynamicInsert
@DynamicUpdate
public class Demo {
    /**
     * 主键
     */
    @Id
    @GeneratedValue
    @Column
    private Integer id;

    /**
     * 类型
     */
    @Column
    private Integer category;

    /**
     * 状态
     *
     * @see com.isoftstone.demo.global.constant.DemoStatus
     */
    @Column
    private Integer status;

    /**
     * 名称
     */
    @Column
    private String name;

    /**
     * 创建人
     */
    @ManyToOne
    @JoinColumn
    private User creator;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = DateUtil.DATE_TIME_FORMAT_DEFAULT)
    @DateTimeFormat(pattern = DateUtil.DATE_TIME_FORMAT_DEFAULT)
    @Column
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;

    /**
     * 筛选 - 起始时间
     */
    @Transient
    @JsonFormat(pattern = DateUtil.DATE_TIME_FORMAT_DEFAULT)
    @DateTimeFormat(pattern = DateUtil.DATE_TIME_FORMAT_DEFAULT)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateStart;

    /**
     * 筛选 - 结束时间
     */
    @Transient
    @JsonFormat(pattern = DateUtil.DATE_TIME_FORMAT_DEFAULT)
    @DateTimeFormat(pattern = DateUtil.DATE_TIME_FORMAT_DEFAULT)
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateEnd;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getCategory() {
        return category;
    }

    public void setCategory(Integer category) {
        this.category = category;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public User getCreator() {
        return creator;
    }

    public void setCreator(User creator) {
        this.creator = creator;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Date getDateStart() {
        return dateStart;
    }

    public void setDateStart(Date dateStart) {
        this.dateStart = dateStart;
    }

    public Date getDateEnd() {
        return dateEnd;
    }

    public void setDateEnd(Date dateEnd) {
        this.dateEnd = dateEnd;
    }
}
